/**
 * Copyright (c) 2015-2016, Michael Yang 杨福海 (fuhai999@gmail.com).
 *
 * Licensed under the GNU Lesser General Public License (LGPL) ,Version 3.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.gnu.org/licenses/lgpl-3.0.txt
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.wzgl.core.baseModel;

import com.jfinal.plugin.activerecord.IBean;
import com.jfinal.plugin.ehcache.CacheKit;
import com.jfinal.plugin.ehcache.IDataLoader;
import com.wzgl.core.base.JModel;
import com.wzgl.message.MessageKit;

/**
 *  Auto generated by JPress, do not modify this file.
 */
@SuppressWarnings("serial")
public abstract class BaseMagic<M extends BaseMagic<M>> extends JModel<M> implements IBean {

	public static final String CACHE_NAME = "magic";
	public static final String METADATA_TYPE = "magic";

	public static final String ACTION_ADD = "magic:add";
	public static final String ACTION_DELETE = "magic:delete";
	public static final String ACTION_UPDATE = "magic:update";

	public void removeCache(Object key){
		if(key == null) return;
		CacheKit.remove(CACHE_NAME, key);
	}

	public void putCache(Object key,Object value){
		CacheKit.put(CACHE_NAME, key, value);
	}

	public M getCache(Object key){
		return CacheKit.get(CACHE_NAME, key);
	}

	public M getCache(Object key,IDataLoader dataloader){
		return CacheKit.get(CACHE_NAME, key, dataloader);
	}



	@Override
	public boolean equals(Object o) {
		if(o == null){ return false; }
		if(!(o instanceof BaseMagic<?>)){return false;}

		BaseMagic<?> m = (BaseMagic<?>) o;
		if(m.getFid() == null){return false;}

		return m.getFid().compareTo(this.getFid()) == 0;
	}

	@Override
	public boolean save() {
		boolean saved = super.save();
		if (saved) { MessageKit.sendMessage(ACTION_ADD, this); }
		return saved;
	}

	@Override
	public boolean delete() {
		boolean deleted = super.delete();
		if (deleted) { MessageKit.sendMessage(ACTION_DELETE, this); }
		return deleted;
	}

	@Override
	public boolean deleteById(Object idValue) {
		boolean deleted = super.deleteById(idValue);
		if (deleted) { MessageKit.sendMessage(ACTION_DELETE, this); }
		return deleted;
	}

	@Override
	public boolean update() {
		boolean update = super.update();
		if (update) { MessageKit.sendMessage(ACTION_UPDATE, this); }
		return update;
	}

	public void setFid(java.lang.String id) {
		set("fid", id);
	}

	public java.lang.String getFid() {
		Object id = get("fid");
		if (id == null)
			return null;
		return id.toString();
	}
	
	public void setFpage(java.lang.String fpage) {
		set("fpage", fpage);
	}

	public java.lang.String getFpage() {
		return get("fpage");
	}
	public void setFurl(java.lang.String furl) {
		set("furl", furl);
	}

	public java.lang.String getFurl() {
		return get("furl");
	}
	
	public void setFstats(java.lang.String fstats) {
		set("fstats", fstats);
	}
	
	public java.lang.String getFstats() {
		return get("fstats");
	}
	public void setFcount(java.lang.Integer fcount) {
		set("fcount", fcount);
	}
	
	public java.lang.Long getFcount() {
		return get("fcount");
	}
	public void setFthread(Integer fthread){
		set("fthread",fthread);
	}
	public Integer getFthread (){
		return get("fthread");
	}

    public void setFtype(String ftype){
    	set("ftype",ftype);
    }
    public String getFtype(){
    	return get("ftype");
    }
    public void setFcycle(String fcycle){
    	set("fcycle",fcycle);
    }
    public String getFcycle(){
    	return get("fcycle");
    }
    public void setFremark(String fremark){
    	set("fremark",fremark);
    }
    public String getFremark(){
    	return get("fremark");
    }
    public void setFclass(String fclass){
    	set("fclass",fclass);
    }
    public String getFclass(){
    	return get("fclass");
    }
    public void setFmodel(String fmodel){
    	set("fmodel",fmodel);
    }
    public String getFmodel(){
    	return get("fmodel");
    }
}
